<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<!-- <link rel="stylesheet" href="/lottery/css/bootstrap.css"> -->
<script type="text/javascript" src="/lottery/js/jquery-1.7.2.js" ></script>
<script type="text/javascript" src="/lottery/js/jquery-validate-1.11.1.js" ></script>
<script type="text/javascript" src="/lottery/js/bootstrap.js"></script>
<style type="text/css">
label.error{color:red}
</style>
<script type="text/javascript">
$(document).ready(function(){
	
	  $("#dopesterForm").validate();
	 
	  $('#submitBtn').click(function(){
		  var validResult = $("#dopesterForm").valid();
		  if (validResult) {
		  $.ajax({    
			    type:'POST',
			    contentType:'application/json; charset=utf-8',
			    url:'ajax/add.do',    
			    data:JSON.stringify({id:$('#id').val(), //为何用$('#dopesterform'.serialize())无法提交 ？
			    	cnName:$('#cnName').val(), 
			    	enName:$('#enName').val(), 
			    	occupation:$('#occupation').val(), 
			    	homePage:$('#homePage').val(), 
			    	fromWhere:$('#fromWhere').val()}), 
			    dataType:'json',  
			    cache: false,
			    success: function(data, textStatus, jqXHR) {    
			        alert(textStatus);
	     			alert($("#dopesterForm").serialize());
	     			
			    },    
			    error: function (XMLHttpRequest, textStatus, errorThrown) {
	                alert(XMLHttpRequest.status + ":" + XMLHttpRequest.statusText);
	     			alert($("#dopesterForm").serialize());
	            }
			});  
	  }
	  });
	});
</script>
</head>
<body>
	<form id="dopesterForm" action="/lottery/dopester/ajax/add.do" method="post">
		<table>
			<tr>
				<td><span>用户ID</span></td>
				<td><input id="id" name="id" type="text" class="required" ></td>
			</tr>
			<tr>
				<td><span>英文名</span></td>
				<td><input id="enName" name="enName" type="text"></td>
			</tr>
			<tr>
				<td><span>中文名</span></td>
				<td><input id="cnName" name="cnName" type="text" class="required"></td>
			</tr>
			<tr>
				<td><span>主页</span></td>
				<td><input id="homePage" name="homePage" type="text" class="required"></td>
			</tr>
			<tr>
				<td><span>职业</span></td>
				<td><select id="occupation" name="occupation" class="required" style="width:153px">
						<option value="0">媒体</option>
						<option value="1">专家</option>
						<option value="2" selected="selected">买家</option>
				</select></td>
			</tr>
			<tr>
				<td><span>来自</span></td>
				<td><select id="fromWhere" name="fromWhere" class="required" style="width:153px">
						<option value="www.500.com" selected="selected">www.500.com</option>
				</select></td>
			</tr>
			<tr>
				<td colspan="2" align="center">
					<input id="submitBtn" type="button" value="提交" />
					<input id="back" type="button" value="返回" />
				</td>
			</tr>
		</table>
	</form>
</body>
</html>